class CartController < ApplicationController
  include ControllerHelper
  before_filter :init, :only => [:show, :update]
  def add
    find_cart.add_items(params[:hash])
    respond_to do |format|
      format.json { render :json => find_cart.get_total }
    end
  end

  def update
    find_cart.update_items(params[:items])
    redirect_to cart_show_path
  end

  def show
    @page["meta"] = false
    if @current_roles.include?("operator") && find_cart.order_id
      redirect_to edit_order_path(:id => find_cart.order_id) and return
    end
    @items = find_cart.get_items
    get_ordered_shops
    @for_operator = false
    @for_edit = true
  end

  def delete
    find_cart.delete_item(params[:id])
    redirect_to cart_show_path
  end

end
